package top.llove.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.llove.mapper.LoveMapper;
import top.llove.service.LoveService;
import top.llove.utils.res.ApiResult;

import java.util.List;

/**
 * 情话ServiceImpl
 *
 * @author: 幸会
 * @date: 2021/7/7 19:07
 * @email: 1846724873@qq.com
 * @description: 情话ServiceImpl
 * version: 1.0
 */
@Slf4j
@Service
public class LoveServiceImpl implements LoveService {
    @Autowired
    private LoveMapper love;
    @Autowired
    private ApiResult res;
    @Override
    public ApiResult select(String id, String text) {

        try {
            List<String> result = love.select(id, text);
            res = result.size() > 0 ? ApiResult.success(200, "搜索成功", result) : ApiResult.fail(200, "暂无收录", false);
            log.info("查询成功，结果：" + res);
        } catch (Exception e) {
            e.printStackTrace();
            res = ApiResult.fail(500, "搜索失败", false);
        }
        return res;
    }
}
